543f5a
@@ -29,6 +29,8 @@
 import org.apache.hadoop.mapred.JobConf;
 
 import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.List;
 import java.util.Properties;
@@ -66,13 +68,17 @@
public static Schema determineSchemaOrThrowException(Properties properties)
       throw new AvroSerdeException(EXCEPTION_MESSAGE);
 
     try {
-      if(schemaString.toLowerCase().startsWith("hdfs://"))
-        return getSchemaFromHDFS(schemaString, new Configuration());
-    } catch(IOException ioe) {
-      throw new AvroSerdeException("Unable to read schema from HDFS: " + schemaString, ioe);
+      Schema s = getSchemaFromFS(schemaString, new Configuration());
+      if (s == null) {
+        //in case schema is not a file system
+        return Schema.parse(new URL(schemaString).openStream());
+      }
+      return s;
+    } catch (IOException ioe) {
+      throw new AvroSerdeException("Unable to read schema from given path: " + schemaString, ioe);
+    } catch (URISyntaxException urie) {
+      throw new AvroSerdeException("Unable to read schema from given path: " + schemaString, urie);
     }
-
-    return Schema.parse(new URL(schemaString).openStream());
   }
 
   /**
@@ -96,13 +102,20 @@
public static Schema determineSchemaOrReturnErrorSchema(Properties props) {
     }
   }
   // Protected for testing and so we can pass in a conf for testing.
-  protected static Schema getSchemaFromHDFS(String schemaHDFSUrl,
-                                            Configuration conf) throws IOException {
-    FileSystem fs = FileSystem.get(conf);
+  protected static Schema getSchemaFromFS(String schemaFSUrl,
+                          Configuration conf) throws IOException, URISyntaxException {
     FSDataInputStream in = null;
-
+    FileSystem fs = null;
+    try {
+      fs = FileSystem.get(new URI(schemaFSUrl), conf);
+    } catch (IOException ioe) {
+      //return null only if the file system in schema is not recognized
+      String msg = "Failed to open file system for uri " + schemaFSUrl + " assuming it is not a FileSystem url";
+      LOG.debug(msg, ioe);
+      return null;
+    }
     try {
-      in = fs.open(new Path(schemaHDFSUrl));
+      in = fs.open(new Path(schemaFSUrl));
       Schema s = Schema.parse(in);
       return s;
     } finally {
